package cn.tedu.live8.service.Impl;

import cn.tedu.live8.mapper.LoginMapper;
import cn.tedu.live8.pojo.dto.LoginDTO;
import cn.tedu.live8.pojo.vo.LoginVO;
import cn.tedu.live8.service.ILoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class LoginServiceImpl implements ILoginService {
    @Autowired
    private LoginMapper loginMapper;

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void login(LoginDTO loginDTO) {
        log.debug("Service中接收到的用户提交的登录数据:{}",loginDTO);
        Authentication authentication=new UsernamePasswordAuthenticationToken(loginDTO.getUsername(),loginDTO.getPassword());
        log.debug("authentication{}:",authentication);
        Authentication authenticate = authenticationManager.authenticate(authentication);
        log.debug("返回的值时:{}",authenticate);
    }
}
